#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <cmath>
using namespace std;
struct San{
    int index;
    int x1,y1;
    int x2,y2;
    double s;
    double w;
};
double calc(San a){
    double ax=(a.x1-a.x2)*(a.x1-a.x2);
    double ay=(a.y1-a.y2)*(a.y1-a.y2);
    double sq=sqrt(ax+ay);
    double ans=a.s*sq;
    ans/=abs(a.x1-a.x2);
    return ans;
}

bool cmp(San a,San b){
   return a.w<b.w;
}
int solve(vector<San> &v,int n){
    sort(v.begin(),v.end(),cmp);
    
    return v[0].index;
}
int main(){
    freopen("in.txt","r",stdin);
    int t;
    cin >> t;
    while(t--){
       
        int n;
        cin >> n;
        vector<San> v(n);
        for(int i=0;i<n;i++){
            cin >> v[i].x1>> v[i].y1 >> v[i].x2>>v[i].y2 >> v[i].s ;
            v[i].index=i+1;
            v[i].w=calc(v[i]);
           // cout << v[i].w <<endl;
        }
        int ans=solve(v,n);
        cout << ans <<endl;

    }
    return 0;
}